// zhouyuyue_yajin/pages/roleSelection/roleSelection.js
let app = getApp();
let http = require('../../util/http.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    student_pic:'../../image/student@2x.png',
    teacher_pic:'../../image/teacher@2x.png',
    role_pic:'../../image/role_bg.png'
  },

  //获取图片
  getPicture:function(){
    let that = this;
    http.get('getPhone',{},function(res){
      if(res.data.data.student_pic!=''){
        that.setData({
          student_pic:res.data.data.student_pic
        });
      };
      if (res.data.data.teacher_pic!='') {
        that.setData({
          teacher_pic:res.data.data.teacher_pic
        });
      };
      if (res.data.data.role_pic!='') {
        that.setData({
          role_pic:res.data.data.role_pic
        });
      };
    });
  },

  //清空购物车
  clearCart:function(){
    let that = this;
    http.get('clearCart',{},function(res){
      wx.switchTab({
        url: '/zhouyuyue_yajin/pages/orderDishes/orderDishes',
      })
    });
  },

  // 跳转预约页面
  gotoAppointment:function(e){
    let that = this;
    app.globalData.role = e.currentTarget.dataset.role;
    that.clearCart();
    // wx.switchTab({
    //   url: '/zhouyuyue_yajin/pages/orderDishes/orderDishes',
    // })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getPicture();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})